package com.sedshop.shop.library.umeng.share;

import android.app.Activity;
import android.graphics.Bitmap;

import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.shareboard.SnsPlatform;
import com.umeng.socialize.utils.ShareBoardlistener;

public class Share {

    public void share(Activity context, String _content, String _url, String _title, String _imageUrl) {
        final SHARE_MEDIA[] displaylist = new SHARE_MEDIA[]{
                SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.QZONE, SHARE_MEDIA.QQ,
                SHARE_MEDIA.SINA, SHARE_MEDIA.EMAIL, SHARE_MEDIA.SMS,};

        new ShareAction(context).setDisplayList(displaylist)
                .withText(_content)
                .withTitle(_title)
//                .withTargetUrl(_url)
                .withMedia(new UMImage(context, _imageUrl))
//                .setContentList(new ShareContent(), new ShareContent())
                .setListenerList(umShareListener, umShareListener)
//                        .setShareboardclickCallback(shareBoardlistener)
                .open();
    }

    public void share(Activity context, String _content, String _url, String _title, Bitmap bitmap) {

        final SHARE_MEDIA[] displaylist = new SHARE_MEDIA[]{
                SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.QZONE, SHARE_MEDIA.QQ,
                SHARE_MEDIA.SINA, SHARE_MEDIA.EMAIL, SHARE_MEDIA.SMS,};

        new ShareAction(context).setDisplayList(displaylist)
                .withText(_content)
//                .withTitle(_title)
//                .withTargetUrl(_url)
//                .withMedia(new UMImage(context, bitmap))
//                .setContentList(new ShareContent(), new ShareContent())
                .setListenerList(umShareListener, umShareListener)
//                        .setShareboardclickCallback(shareBoardlistener)
                .open();
    }

    private UMShareListener umShareListener = new UMShareListener() {
        @Override
        public void onResult(SHARE_MEDIA platform) {
        }

        @Override
        public void onError(SHARE_MEDIA platform, Throwable t) {
        }

        @Override
        public void onCancel(SHARE_MEDIA platform) {
        }
    };
    private ShareBoardlistener shareBoardlistener = new ShareBoardlistener() {

        @Override
        public void onclick(SnsPlatform snsPlatform, SHARE_MEDIA share_media) {
//            new ShareAction(ShareActivity.this).setPlatform(share_media).setCallback
//                    .withText("多平台分享")
//                    .share();
        }
    };
}
